import pickle
import linecache


def writebunchobj(path,bunchobj):
    with open(path,'wb') as f_obj:
        pickle.dump(bunchobj,f_obj)
    f_obj.close()

def readbunchobj(path):
    with open(path,'rb') as f_obj:
        bunch = pickle.load(f_obj)
    f_obj.close()
    return bunch 

def readfile(path):
    with open(path, "rb") as fp:
        content = fp.read()
    return content

'''读取特定的行数'''
def get_line_content(file,page):
    content = linecache.getline(file,page)
    return content
'''读取txt文件总行数'''
def get_txt_linecount(file):
    txt = open(file,'rb') 
    data = txt.read().decode('utf-8')
    txt.close()
    ##获取txt的总行数
    line_c = data.count('\n')
    return line_c